"""LLM Plays Pokemon 工具定义模块"""

from typing import Dict, Any, List

# 定义工具列表，用于函数调用
def get_emulator_tool_definition() -> Dict[str, Any]:
    """获取模拟器工具定义
    
    Returns:
        模拟器工具定义
    """
    return {
        "type": "function",
        "function": {
            "name": "use_emulator",
            "description": "发送按钮指令到游戏模拟器",
            "parameters": {
                "type": "object",
                "properties": {
                    "buttons": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": "按钮序列，如[\"A\", \"B\", \"Up\"]"
                    },
                    "pause_ms": {
                        "type": "integer",
                        "description": "执行后暂停的毫秒数（可选）"
                    }
                },
                "required": ["buttons"]
            }
        }
    }

def get_navigator_tool_definition() -> Dict[str, Any]:
    """获取导航工具定义
    
    Returns:
        导航工具定义
    """
    return {
        "type": "function",
        "function": {
            "name": "navigator",
            "description": "在游戏中导航到指定位置或执行特定操作",
            "parameters": {
                "type": "object",
                "properties": {
                    "target": {
                        "type": "object",
                        "description": "目标信息，可以是坐标、场景或操作"
                    }
                },
                "required": ["target"]
            }
        }
    }

def get_knowledge_base_tool_definition() -> Dict[str, Any]:
    """获取知识库工具定义
    
    Returns:
        知识库工具定义
    """
    return {
        "type": "function",
        "function": {
            "name": "update_knowledge_base",
            "description": "更新知识库",
            "parameters": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "description": "操作类型，可选值：'add', 'update', 'delete', 'get'"
                    },
                    "section_id": {
                        "type": "string",
                        "description": "部分ID"
                    },
                    "content": {
                        "type": "string",
                        "description": "部分内容，仅在add和update操作时需要"
                    }
                },
                "required": ["operation", "section_id"]
            }
        }
    }

def get_all_tools_definition() -> List[Dict[str, Any]]:
    """获取所有工具定义
    
    Returns:
        所有工具定义列表
    """
    return [
        get_emulator_tool_definition(),
        get_navigator_tool_definition(),
        get_knowledge_base_tool_definition()
    ]

def get_emulator_only_tools_definition() -> List[Dict[str, Any]]:
    """获取仅包含模拟器工具的定义
    
    Returns:
        仅包含模拟器工具的定义列表
    """
    return [get_emulator_tool_definition()]